<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="ajax.js"></script>
    <script>
        window.onload=function(){
            var oBtn=document.getElementById('btn');

            oBtn.onclick=function(){

                if(window.XMLHttpRequest){
                   var oAjax=new XMLHttpRequest()
                }else{
                   var oAjax=new ActiveXObject('Microsoft.XMLHTTP')
;                }
                 //建立连接

                oAjax.open('GET',url,true);

            }
        }
    </script>
</head>
<body>
    <input type="button" value="按钮" id="btn">
</body>
</html>